package com.blue.waffle.iwc.domains;

import java.util.ArrayList;
import java.util.Map;

public class Profile {
	private int id;
	
	private String name;
	private long levelRandomSeed=0;
	private long lastPlayedLevelIndex=-1;
	private int attempts;
	private Difficulty currentDifficulty;
	
	private Map<Integer, Achievement> achievements;
	private ArrayList<Level> completedLevels;
	
	public static final String ID="id";
	public static final String NAME="name";
	public static final String LEVEL_RANDOM_SEED="level_random_seed";
	public static final String LAST_PLAYED_LEVEL_INDEX="last_played_level_index";
	public static final String CURRENT_DIFFICULTY="current_difficulty";
	public static final String ATTEMPT="attempts";
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Map<Integer, Achievement> getAchievements() {
		return achievements;
	}
	public void setAchievements(Map<Integer, Achievement> achievements) {
		this.achievements = achievements;
	}
	public ArrayList<Level> getCompletedLevels() {
		return completedLevels;
	}
	public void setCompletedLevels(ArrayList<Level> completedLevels) {
		this.completedLevels = completedLevels;
	}
	
	public Profile(){
		this.id=0;
		this.name=null;
		this.currentDifficulty=new Difficulty();
		this.lastPlayedLevelIndex=-1;
	}
	
	public long getLastPlayedLevel() {
		return lastPlayedLevelIndex;
	}
	public void setLastPlayedLevel(long lastPlayedLevel) {
		this.lastPlayedLevelIndex = lastPlayedLevel;
	}
	
	public long getLevelRandomSeed() {
		return levelRandomSeed;
	}
	public void setLevelRandomSeed(long levelRandomSeed) {
		this.levelRandomSeed = levelRandomSeed;
	}
	public Difficulty getCurrentDifficulty() {
		return currentDifficulty;
	}
	public void setCurrentDifficulty(Difficulty currentDifficulty) {
		this.currentDifficulty = currentDifficulty;
		//this.attempts=Difficulties.getDifficulty(currentDifficulty.getId()).getAttempts();
	}
	
	public void setCurrentDifficulty(int difficultyId){
		if (this.currentDifficulty==null || this.currentDifficulty.getId()!=difficultyId) {
			Difficulty difficulty=new Difficulty();
			difficulty.setId(difficultyId);
			this.currentDifficulty=difficulty;
			this.attempts=Difficulties.getDifficulty(difficultyId).getAttempts();
		}
	}
	
	public long getNextLevelIndex(){
		return lastPlayedLevelIndex+1;
	}
	public int getAttempts() {
		return attempts;
	}
	public void setAttempts(int attempts) {
		this.attempts = attempts;
	}
	
}
